{extend name="layouts/main" /}
{block name="content"}
<div class="layui-tab layui-tab-brief" lay-filter="demoTitle">
	<div class="layui-body layui-tab-content site-demo site-demo-body" style="top: 0px;left: 0px;">
		<div class="layui-tab-item layui-show">
			<div class="layui-main">
				<div id="LAY_preview">
					<form class="layui-form layui-form-pane form-horizontal" action="{:url('')}" method="post">
						<div class="layui-form-item">
							<label class="layui-form-label">中文名称</label>
							<div class="layui-input-block">
								<input type="text"  name="title"  value="{$info.title|default=''}" autocomplete="off" placeholder="请输入" class="layui-input upload-text">
								<span class="layui-form-mid layui-word-aux">
									[ 配置中文名称 ]
								</span>
								<span class="sysval"><em class="zerocopy">title</em></span>
							</div>
						</div>
						<div class="layui-form-item">
							<label class="layui-form-label">英文名称</label>
							<div class="layui-input-block">
								<input type="text" name="name" value="{$info.name|default=''}" autocomplete="off" placeholder="请输入" class="layui-input upload-text">
								<span class="layui-form-mid layui-word-aux">
									[ 英文名称 ]
								</span>
								<span class="sysval"><em class="zerocopy">name</em></span>
							</div>
						</div>
						<div class="layui-form-item">
							<label class="layui-form-label">配置类型</label>
							<div class="layui-input-block">
								<select name="typeid" lay-verify="required" class="upload-select">
									<option value="" selected="selected"></option>
									{volist name="configTypeRes" id="ct"}
									<option value="{$ct.id}">{$ct.title}</option>
									{/volist}
								</select>
								<span class="layui-form-mid layui-word-aux">
									[ 配置类型 ]
								</span>
								<span class="sysval"><em class="zerocopy">typeid</em></span>
							</div>
						</div>
						<div class="layui-form-item">
							<label class="layui-form-label">字段类型</label>
							<div class="layui-input-block">
								<select name="type" lay-filter="type" lay-verify="required" class="upload-select" id="data-type">
									<option value="">----请选择----</option>
									{volist name=":get_attribute_type()" id="vo"}
									<option value="{$key}" rule="{$vo[1]}">{$vo[0]}</option>
									{/volist}
								</select>
								<span class="layui-form-mid layui-word-aux">
									[ 用于表单中的展示方式 ]
								</span>
								<span class="sysval"><em class="zerocopy">type</em></span>
							</div>
						</div>
						<div id="custom" class="layui-form-item" {if $info.type!='custom'}style="display: none;"{/if}>
							<label class="layui-form-label">自定义模板</label>
							<div class="layui-input-block">
								<select name="setting[custom]" lay-verify="required" class="upload-select">
									<option value="custom.html" selected>默认模板:custom.html</option>
									{volist name="custom" id="vo"}
									<option value="{$vo}" {if isset($info['setting']['custom']) && $info.setting.custom==$vo}selected{/if}>{$vo}</option>
									{/volist}
								</select>
								<span class="layui-form-mid layui-word-aux">
									[ 新增模板以custom_xx.html形式<br>模板位于app/admin/view/cms/custom目录下 ]
								</span>
								<span class="sysval"><em class="zerocopy">setting[custom]</em></span>
							</div>
						</div>
						<div class="layui-form-item layui-form-text">
							<label class="layui-form-label">可选值<span class="sysval"><em class="zerocopy">extra</em></span></label>
							<div class="layui-input-block">
								<textarea name="extra" placeholder="" class="layui-textarea upload-text">{$info.extra|default=''}</textarea>
								<span class="layui-form-mid layui-word-aux">
										可选值，以下两种都可以：<br>
										<!-- 1、如可选值有说明则在每个可选值后面加:说明，多个可选值用逗号隔开，例：值:说明,值:说明 或 值,值 configuration.html中用第一种方法时用 <br> -->
										1、多个可选值用逗号隔开。注：必须加说明，例：值:说明,值:说明<!--configuration.html中用第二种方法时用--> <br>
										2、如果是枚举型，需要配置该项，一行一个选项，例: <br>
										0:选项1 <br>
										2:选项2 <br>
								</span>
							</div>
						</div>
						<div id="options" class="layui-form-item layui-form-text" {if !$info || !in_array($info['type'],['datetime','selectpage','picture','piclist','image','images','file','filelist','fileo','files','onevideo','videolist'])} style="display: none;" {/if}>
							<label class="layui-form-label">
								扩展参数
								<i class="fa fa-question-circle options-question" title="有疑问吗？点击这里！"></i>
								<span class="sysval"><em class="zerocopy">setting[options]</em></span>
							</label>
							<div class="layui-input-block">
								<textarea name="setting[options]" placeholder="" class="layui-textarea upload-text">{$info.setting.options|default=''}</textarea>
								<span class="layui-form-mid layui-word-aux" id="options-question" style="display: none;">
								高级下拉框配置：<br>
									url:提供数据源的URL地址<br>
									field:列表显示读取的字段,默认[name]<br>
									key:列表选中后渲染的字段,默认[id]<br>
									pagination:是否开启分页,默认[true]<br>
									limit:分页大小,默认[10]<br>
									multiple:是否支持多选,默认[false]<br>
									max:最多可选择数量<br>
									order:排序字段，默认[id]<br>
								附件配置：<br>
									iscrop:是否上传后自动展示裁剪界面,默认[0]<br>
									size:附件大小限制单位KB,默认无限制[0]<br>
									ext:,附件格式限制,例:png,jpeg,默认['']<br>
									thumb:缩略图参数,例:WEB_ENABLE_THUMB=1&WEB_THUMB_WIDTH=150&WEB_THUMB_HEIGHT=150&WEB_THUMB_TYPE=1&WEB_THUMB_SAVE_TYPE=png&WEB_THUMB_QUALITY=80&WEB_THUMB_INTERLACE=1<br>
									watermark:水印参数,例:WEB_ENABLE_WATER=1&WEB_WATER_TYPE=1&WEB_WATER_IMG=uploads/config/20201228/rOvDya20201228.png&WEB_WATER_TEXT=zengcms&WEB_WATER_TEXT_SIZE=30&WEB_WATER_TEXT_COLOR=#FF0000&WEB_WATER_TMD=50&WEB_WATER_POS=8<br>
								日期和时间配置：<br>
									type:类型：String，默认值：datetime <br>
									format:类型：String，默认值：yyyy-MM-dd HH:mm:ss <br>
									pformat:值转换：默认值：Y-m-d H:i:s
									range:开启左右面板范围选择，类型：Boolean/String，默认值：false，如果设置 true，将默认采用 “ - ” 分割。 你也可以直接设置 分割字符，range: '~' 来自定义分割字符<br>
							</span>
							</div>
						</div>
						<div class="layui-form-item layui-form-text">
							<label class="layui-form-label">默认值<span class="sysval"><em class="zerocopy">value</em></span></label>
							<div class="layui-input-block">
								<textarea name="value" placeholder="" class="layui-textarea data-value upload-text">{$info.value|default=''}</textarea>
								<span class="layui-form-mid layui-word-aux">
									[ 默认值，多个用逗号隔开 ]
								</span>
							</div>
						</div>
						<div class="layui-form-item layui-form-text">
							<label class="layui-form-label">配置说明<span class="sysval"><em class="zerocopy">remark</em></span></label>
							<div class="layui-input-block">
								<textarea name="remark" placeholder="" class="layui-textarea upload-text">{$info.remark|default=''}</textarea>
								<span class="layui-form-mid layui-word-aux">
									[ 配置说明 ]
								</span>
							</div>
						</div>
						<div class="layui-form-item">
							<label class="layui-form-label">核心配置</label>
							<div class="layui-input-block">
								<select name="iscore" lay-verify="required"  class="upload-select">
									<option value="1" selected="selected">是</option>
									<option value="0" selected="selected">否</option>
								</select>
								<span class="layui-form-mid layui-word-aux">
									[ 核心配置 ]
								</span>
								<span class="sysval"><em class="zerocopy">iscore</em></span>
							</div>
						</div>
						<div class="layui-form-item" pane="">
							<label class="layui-form-label">状态</label>
							<div class="layui-input-block">
								<input type="radio" name="status" value="1" title="显示" checked="" class="upload-radio">
								<input type="radio" name="status" value="0" title="隐藏" class="upload-radio">
								<span class="sysval"><em class="zerocopy">status</em></span>
							</div>
						</div>
						<div class="layui-form-item">
							<label class="layui-form-label">排序</label>
							<div class="layui-input-block">
								<input type="text" name="sort" value="{$info.sort|default='0'}" required="" lay-verify="required" placeholder="排序" autocomplete="off" class="layui-input upload-text">
								<span class="layui-form-mid layui-word-aux">
									[ 排序 ]
								</span>
								<span class="sysval"><em class="zerocopy">sort</em></span>
							</div>
						</div>
						<div class="layui-form-item">
							<div class="layui-input-block" style="border: 0px;">
								<input type="hidden" name="id" value="{$info.id|default=''}" class="upload-text">
								<button class="layui-btn x_admin_close ajax-post2" type="submit" target-form="form-horizontal" lay-submit="" lay-filter="formDemo">提交保存</button>
								<!-- <button type="reset" class="layui-btn layui-btn-danger">重置</button>
								<a class="layui-btn layui-btn-primary" href="javascript:;" onclick="history.go(-1);">返回</a> -->
							</div>
						</div>
					</form>
				</div>
			</div>
		</div>
	</div>
</div>
{/block}
{block name="js"}
<script type="text/javascript">
    $("select[name='type']").val("{$info.type|default = ''}");
    $("select[name='typeid']").val({$info.typeid|default = $typeid});
    $("input[name=status][value={$info.status|default = 1}]").attr("checked","checked");
    $("select[name='iscore']").val("{$info.iscore|default = '0'}");
	var vl = $('#data-type').find('option:selected').val();
	if(vl == 'textarea' || vl == 'datetime' || vl == 'editor'){
		$('.data-value').attr("disabled",true).attr("placeholder","当前字段类型不能添加默认值！").attr("value","");
	}else{
		$('.data-value').attr("disabled",false).attr("placeholder","");
	}
	layui.use(['form','layer','element','jquery'], function(){
		var form = layui.form
		,layer = layui.layer
		,element = layui.element
		,$ = layui.jquery;
		form.on('select(type)', function(data) {
			// console.log(data.elem);//得到select原始DOM对象
		  	// console.log(data.value);//得到被选中的值
		 	// console.log(data.othis);//得到美化后的DOM对象
		  	// alert(data.value);
		  	// alert($(data.elem).find('option:selected').attr('rule'));
			// if(vl == 'array' || vl == 'radio'){
			// 	$("#extra").show();
			// }else{
			// 	$("#extra").hide();
			// }
			var vl = data.value;
			if(vl == 'textarea' || vl == 'datetime' || vl == 'editor' || vl == 'ueditor'){
				$('.data-value').attr("disabled",true).attr("placeholder","当前字段类型不能添加默认值！").attr("value","");
			}else{
				$('.data-value').attr("disabled",false).attr("placeholder","");
			}
			if(vl == 'custom'){
				$("#custom").show();
			}else{
				$("#custom").hide();
			}
			if(vl == 'datetime' || vl == 'selectpage' || vl == 'picture' || vl == 'piclist' || vl == 'image' || vl == 'images' || vl == 'file' || vl == 'filelist' || vl == 'fileo' || vl == 'files' || vl == 'onevideo' || vl == 'videolist'){
				$("#options").show();
			}else{
				$("#options").hide();
			}
			if(vl == 'array' || vl == 'radio' || vl == 'checkbox' || vl == 'select' || vl == 'selecto' || vl == 'selects'){
				$("#extra").show();
			}else{
				$("#extra").hide();
			}
	    });
	});
</script>
{/block}